package leetcode;

/**
 * Created by Ghost on 2014/11/12 0012.
 */
public class Valid_Palindrome {
    public boolean isPalindrome(String s) {
        char[] chars = s.replaceAll("[^a-zA-Z\\d]","").toLowerCase().toCharArray();

        int begin = 0,end = chars.length-1;
        while(begin<=end){
            if(chars[begin]==chars[end]){
                begin++;
                end--;
            }
            else
                return false;
        }
        return true;
    }
    public static void main(String[] args){
        Valid_Palindrome valid_palindrome = new Valid_Palindrome();
        System.out.println(valid_palindrome.isPalindrome("A man, a plan, a canal: Panama"));
    }
}
